Skip to content

feat(raycicmd): integrate matrix expansion into pipeline conversion#379

Open
andrew-anyscale wants to merge 1 commit intoandrew/revup/main/matrix-expandfrom
andrew/revup/main/matrix-converter
Open

feat(raycicmd): integrate matrix expansion into pipeline conversion#379
andrew-anyscale wants to merge 1 commit intoandrew/revup/main/matrix-expandfrom
andrew/revup/main/matrix-converter

Conversation

@andrew-anyscale
Copy link
Contributor

@andrew-anyscale andrew-anyscale commented Jan 20, 2026

Wire matrix expansion into the step conversion flow. Matrix steps are expanded inline during conversion, with a meta wait-step created to preserve the original key for backwards-compatible depends_on references.

Auto-Generated Tags

Each expanded step receives auto-generated tags based on matrix values:
python-3.11, cuda-12.1.1

These tags integrate with rayci's tag filtering system, allowing selective
runs like "only run python-3.11 tests" via tag rules.

Meta-Step Pattern

The meta wait-step preserves backwards compatibility:

  • Key: original step key (e.g., "ray-build")
  • Type: wait step
  • depends_on: all expanded step keys

This allows existing depends_on: ray-build references to wait for ALL
matrix instances without modification.

Filtering Behavior

When tag filtering is applied:

  • Only matching expanded steps are included
  • If a step depends on the meta-step, ALL instances are pulled in
  • If a step uses selector syntax, only matching instances are included
  • If all instances are filtered out, the meta-step is also excluded

Topic: matrix-converter
Relative: matrix-expand

Signed-off-by: andrew andrew@anyscale.com

@andrew-anyscale
Copy link
Contributor Author

andrew-anyscale commented Jan 20, 2026

Reviews in this chain:
#378 feat(raycicmd): add matrix expansion types and selector resolution
 └#379 feat(raycicmd): integrate matrix expansion into pipeline conversion

@andrew-anyscale
Copy link
Contributor Author

andrew-anyscale commented Jan 20, 2026

# head base diff date summary
0 7a80735b 74665960 diff Jan 20 13:04 PM 3 files changed, 412 insertions(+), 5 deletions(-)
1 5b00dd84 853ec652 diff Jan 20 13:06 PM 1 file changed, 8 insertions(+), 8 deletions(-)
2 914104fd 7450d3e3 diff Jan 20 13:31 PM 1 file changed, 9 insertions(+), 9 deletions(-)
3 7b592fa3 b7b5455b rebase Jan 20 13:39 PM 0 files changed
4 700f6d95 b488745a diff Jan 20 13:56 PM 3 files changed, 96 insertions(+), 9 deletions(-)
5 18a25dbd b488745a diff Jan 20 14:13 PM 2 files changed, 35 insertions(+), 51 deletions(-)
6 c5e6aa83 b488745a diff Jan 20 14:19 PM 1 file changed, 1 insertion(+), 1 deletion(-)
7 feac46f5 b488745a diff Jan 20 14:50 PM 2 files changed, 6 insertions(+), 3 deletions(-)
8 4c8d9d26 b488745a diff Jan 20 14:55 PM 1 file changed, 1 insertion(+)
9 83f7a551 bc2e07e6 diff Jan 26 11:22 AM 1 file changed, 5 insertions(+), 11 deletions(-)
10 2d792f3d 570e6e75 diff Jan 26 11:32 AM 1 file changed, 13 insertions(+), 19 deletions(-)
11 4214f2b7 268d356a rebase Jan 26 11:42 AM 0 files changed
12 0be5ac95 24b799ad diff Feb 5 17:17 PM 1 file changed, 1 insertion(+), 1 deletion(-)
13 ff09e880 cbb9612b diff Feb 5 17:26 PM 0 files changed
14 a9a0117a 4ce2802a diff Feb 5 17:29 PM 0 files changed
15 b8182dd4 4ce2802a diff Feb 5 17:32 PM 1 file changed, 1 deletion(-)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @andrew-anyscale, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the CI/CD pipeline's flexibility and efficiency by implementing dynamic matrix expansion and selective dependency management. It allows for the generation of specific pipeline steps based on matrix configurations and enables subsequent steps to depend only on relevant matrix variants. This improvement streamlines the build process by preventing the execution of redundant steps and provides finer control over pipeline dependencies.

Highlights

  • Matrix Expansion: Introduced the capability to expand matrix-defined steps within the pipeline, generating individual steps for each matrix variant.
  • Selective Dependency: Enabled pipeline steps to selectively depend on a subset of matrix-defined steps, allowing for more granular control and efficient execution.
  • Tag Filtering Integration: Integrated tag filtering with matrix expansion, allowing unnecessary matrix variants to be filtered out, reducing overall build time.
  • New Configuration and Tests: Added a new YAML configuration for matrix selection tests and comprehensive unit tests to validate the matrix expansion and filtering logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from 7466596 to 853ec65 Compare January 20, 2026 21:06
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 7a80735 to 5b00dd8 Compare January 20, 2026 21:06
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a powerful matrix expansion and filtering feature for raycicmd. The implementation is well-structured, separating the matrix expansion logic into a new matrix_expand.go file and integrating it into the existing converter.go.

The changes include:

  • Pre-processing of pipeline steps to expand matrix definitions into individual steps.
  • Generation of a meta wait step to allow dependencies on an entire matrix.
  • Automatic generation of tags for each matrix instance to enable fine-grained filtering.
  • Expansion of depends_on selectors to target specific matrix instances.

The new functionality is thoroughly tested, covering expansion, dependency selection, tag filtering, and error conditions like missing label placeholders. A new Buildkite pipeline configuration is also added for integration testing.

I have one suggestion regarding the deep copy mechanism to make it more robust against future changes. Overall, this is a great addition that significantly enhances pipeline configuration capabilities.

@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 5b00dd8 to 914104f Compare January 20, 2026 21:31
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch 2 times, most recently from 7450d3e to b7b5455 Compare January 20, 2026 21:39
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 914104f to 7b592fa Compare January 20, 2026 21:39
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from b7b5455 to b488745 Compare January 20, 2026 21:56
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch 3 times, most recently from c5e6aa8 to feac46f Compare January 20, 2026 22:50
@andrew-anyscale andrew-anyscale mentioned this pull request Jan 20, 2026
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch 2 times, most recently from 4c8d9d2 to 83f7a55 Compare January 26, 2026 19:22
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from b488745 to bc2e07e Compare January 26, 2026 19:22
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 83f7a55 to 2d792f3 Compare January 26, 2026 19:32
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from bc2e07e to 570e6e7 Compare January 26, 2026 19:32
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 2d792f3 to 4214f2b Compare January 26, 2026 19:42
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from 570e6e7 to 268d356 Compare January 26, 2026 19:42
@gitar-bot
Copy link

gitar-bot bot commented Jan 26, 2026

Code Review 👍 Approved with suggestions 1 resolved / 4 findings

Solid implementation of matrix expansion and filtering. Previous edge case findings regarding unchecked type assertions and silent failures remain unaddressed in this revision.

💡 Edge Case: Unchecked type assertion may panic on malformed step

📄 raycicmd/converter.go:128

At line 128, inst.substituteValues(step).(map[string]any) performs a type assertion without checking if the result is nil or of the expected type. If substituteValues returns an unexpected type (e.g., due to malformed input), this will cause a runtime panic.

Impact: Pipeline conversion could crash on edge case inputs.

Suggested fix: Use a type assertion with ok check:

expandedStepRaw := inst.substituteValues(step)
expandedStep, ok := expandedStepRaw.(map[string]any)
if !ok {
    return nil, nil, fmt.Errorf("matrix step %q: substitution returned unexpected type", baseKey)
}
💡 Edge Case: Silent failure when matrix selector matches no instances

📄 raycicmd/converter.go:178-185

When expandMatrixSelector() returns an empty slice (no matches for the given matrix filter), the code silently continues without appending anything to the result. This could lead to confusing behavior where a user specifies a dependency on a matrix selector that matches nothing (e.g., typo in variant name like python: "3.12" when only 3.10 and 3.11 exist).

Consider adding validation to warn or error when a matrix selector matches zero instances:

matches, err := expandMatrixSelector(sel, ctx.registry, ctx.expandedKeys)
if err != nil {
    return nil, err
}
if len(matches) == 0 {
    return nil, fmt.Errorf("matrix selector for key %q matched no instances", sel.Key)
}
result = append(result, matches...)

This would catch configuration errors early rather than silently dropping dependencies.

💡 Edge Case: Missing validation for empty depends_on after expansion

📄 raycicmd/converter.go:167

In expandDependsOnSelectors, when a matrix selector doesn't match any expanded keys (e.g., selector specifies a matrix value that doesn't exist), expandMatrixSelector returns an empty slice. This is appended to the result, but there's no check to warn or error when no keys matched.

If a user specifies:

depends_on:
  - key: build-step
    matrix:
      python: "3.99"  # non-existent variant

The dependency would silently resolve to nothing, which could lead to steps running earlier than intended or missing required dependencies.

Suggestion: Consider either returning an error when expandMatrixSelector returns zero matches, or logging a warning. At minimum, document this behavior.

✅ 1 resolved
Edge Case: Meta wait-step lacks tags, preventing tag-based filtering

📄 raycicmd/converter.go:152
The meta wait-step created for matrix expansion does not inherit any tags from the original step:

metaStep := map[string]any{
    "wait":       nil,
    "key":        baseKey,
    "depends_on": expandedKeysList,
}

This means if a user filters by tags (e.g., python-3.11), the meta wait-step will be excluded since it has no tags. While this may be intentional (the test at line 1131 expects only 1 step when filtering), it could lead to unexpected behavior if downstream steps depend on the base key expecting all variants to complete.

Suggestion: Consider documenting this behavior clearly, or optionally adding an "always" tag or special handling for meta wait-steps to ensure they're included when any of their expanded steps match the filter.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@andrew-anyscale andrew-anyscale changed the title feat(raycicmd): add matrix expansion and filtering support feat(raycicmd): integrate matrix expansion into pipeline conversion Feb 6, 2026
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from 4214f2b to 0be5ac9 Compare February 6, 2026 01:18
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch 2 times, most recently from 24b799a to cbb9612 Compare February 6, 2026 01:26
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch 2 times, most recently from ff09e88 to a9a0117 Compare February 6, 2026 01:29
@andrew-anyscale andrew-anyscale marked this pull request as ready for review February 6, 2026 01:29
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-expand branch from cbb9612 to 4ce2802 Compare February 6, 2026 01:29
Wire matrix expansion into the step conversion flow. Matrix steps are expanded inline during conversion, with a meta wait-step created to preserve the original key for backwards-compatible depends_on references.

## Auto-Generated Tags

Each expanded step receives auto-generated tags based on matrix values:
  python-3.11, cuda-12.1.1

These tags integrate with rayci's tag filtering system, allowing selective
runs like "only run python-3.11 tests" via tag rules.

## Meta-Step Pattern

The meta wait-step preserves backwards compatibility:
  - Key: original step key (e.g., "ray-build")
  - Type: wait step
  - depends_on: all expanded step keys

This allows existing `depends_on: ray-build` references to wait for ALL
matrix instances without modification.

## Filtering Behavior

When tag filtering is applied:
- Only matching expanded steps are included
- If a step depends on the meta-step, ALL instances are pulled in
- If a step uses selector syntax, only matching instances are included
- If all instances are filtered out, the meta-step is also excluded

Topic: matrix-converter
Relative: matrix-expand

Signed-off-by: andrew <andrew@anyscale.com>
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/matrix-converter branch from a9a0117 to b8182dd Compare February 6, 2026 01:32
@andrew-anyscale
Copy link
Contributor Author

Example:

group: matrix selection test
tags:
  - matrix-test
steps:
  # Matrix step with 5 values - only "selected-1" and "selected-2" should be run
  # when filtered (others are skipped)
  - label: "Matrix {{matrix.variant}}"
    key: matrix-step
    command: |
      echo "Running variant: {{matrix.variant}}"
      if [ "{{matrix.variant}}" != "selected-1" ] && [ "{{matrix.variant}}" != "selected-2" ]; then
        echo "ERROR: This variant should not have been spawned!"
        echo "Only 'selected-1' and 'selected-2' variants should run when matrix-test tag is used."
        exit 1
      fi
      echo "Correct variant spawned."
    depends_on: forge
    matrix:
      setup:
        variant:
          - "selected-1"
          - "selected-2"
          - "skipped-1"
          - "skipped-2"
          - "skipped-3"

  # This step depends on only the "selected" variants
  - label: "Depends on selected only"
    key: depends-on-selected
    command: echo "This step depends on only the selected variants"
    depends_on:
      - key: matrix-step
        matrix:
          variant: ["selected-1", "selected-2"]
      - forge

  - label: "Final validation"
    tags: always
    key: final-validation
    command: echo "Final validation"
    depends_on: depends-on-selected
Screenshot 2026-02-05 at 5 33 43 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant